package com.andnnl.action;

import com.andnnl.service.base.EmasUcinfoService;
import com.andnnl.service.sms.EmasSMSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by chenss on 2019/7/18.
 */
@Controller
public class IndexController {
    @Autowired
    EmasUcinfoService emasUcinfoService;

    @Autowired
    EmasSMSService emasSMSService;

    @RequestMapping({"/","/index"})
    public ModelAndView index() {
        ModelAndView view = new ModelAndView("/index.html");
        view.addObject("list", emasUcinfoService.getList());
        return view;
    }

    @RequestMapping("/insert/{username}")
    public ModelAndView insert(@PathVariable String username) {
        ModelAndView view = new ModelAndView("/index.html");
        emasUcinfoService.insert(username);
        view.addObject("list", emasUcinfoService.getList());
        return view;
    }

    @RequestMapping("/del/{username}")
    public ModelAndView del(@PathVariable String username) {
        ModelAndView view = new ModelAndView("/index.html");
        emasUcinfoService.del(username);
        view.addObject("list", emasUcinfoService.getList());
        return view;
    }

    @RequestMapping("/index2")
    public ModelAndView index2() {
        ModelAndView view = new ModelAndView("/index.html");
        view.addObject("list", emasSMSService.getList());
        return view;
    }
    @RequestMapping("/group")
    public ModelAndView group() {
        ModelAndView view = new ModelAndView("/group.html");
        view.addObject("list", emasSMSService.getGroupList());
        return view;
    }
}
